// database.js
const { Sequelize } = require('sequelize');
const config = require('../config');

const sequelize = new Sequelize(
  config.database,
  config.username,
  config.password,
  {
    host: config.host,
    dialect: config.dialect,
    logging: config.logging,
    // 其他 Sequelize 选项...
  }
);

// 同步模型到数据库
sequelize.sync().then(() => {
  console.log('Database and tables synced');
}).catch(err => {
  console.error('Error syncing database', err);
});

module.exports = sequelize;